#include <stdlib.h>

#include "lib.h"

#include "slotguts.h"
#include "rwbguts.h"



enum WheelContents
{
    BLANK,
    BAR1,
    BAR2,
    BAR3,
    RED7,
    BLUE7,
    WHITE7,
};


enum SpinResult
{
	EVT_LOSER = 0,
	EVT_ANY3BARS,
	EVT_3BAR1,
	EVT_3BAR2,
	EVT_ANY3SEVENS,
	EVT_3BAR3,
	EVT_3BLUE7,
	EVT_BAR1BAR2BAR3,
	EVT_3WHITE7,
	EVT_3RED7,
	EVT_RWB7,
	NUMEVENTS
};

bool8 
RWBSlotGuts::isValidGuts()
{
    return (getGutsId() >= 300 &&
            getGutsId() <= 349);
}




uint8
RWBSlotGuts::classifyStops(uint8* stops,uint8 bet, uint8 line)
{
	uint8 result = EVT_LOSER;

	// 3-in-a-row
	//
	if ( getIcon(0, stops[0])->iconid == getIcon(1, stops[1])->iconid &&
		getIcon(1, stops[1])->iconid == getIcon(2, stops[2])->iconid)
	{
		switch ( getIcon(0, stops[0])->iconid )
		{
			case BAR1:
                result = EVT_3BAR1;
                break;

			case BAR2:
                result = EVT_3BAR2;
                break;

			case BAR3:
                result = EVT_3BAR3;
                break;

			case RED7:
                result = EVT_3RED7;
                break;

			case WHITE7:
                result = EVT_3WHITE7;
                break;

			case BLUE7:
                result = EVT_3BLUE7;
                break;
			default:
				break;
		}
	}
	else
	{
		int i, bars = 0, sevens = 0;

		for (i = 0; i < getReelCount(); i++)
			switch ( getIcon(i, stops[i])->iconid )
			{
                case RED7:
				case WHITE7:
                case BLUE7:
					++sevens;
					break;

                case BAR1:
				case BAR2:
				case BAR3:
					++bars;
					break;

				default:
					break;
			}

		if (bars == 3)
        {
            if ( getIcon(0, stops[0])->iconid == BAR1 && 
                 getIcon(1, stops[1])->iconid == BAR2 &&
                 getIcon(2, stops[2])->iconid == BAR3 )
            {
                result = EVT_BAR1BAR2BAR3;
            }
            else
            {
                result = EVT_ANY3BARS;
            }
        }
		else if (sevens == 3)
        {
            if ( getIcon(0, stops[0])->iconid == RED7 && 
                 getIcon(1, stops[1])->iconid == WHITE7 &&
                 getIcon(2, stops[2])->iconid == BLUE7 )
            {
                result = EVT_RWB7;
            }
            else
            {
                result = EVT_ANY3SEVENS;
            }
        }
	}

	return result;
}


